from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
driver = webdriver.Chrome()


class TrainSpider(object):
    login_url = 'https://kyfw.12306.cn/otn/resources/login.html'
    profile_url = 'https://kyfw.12306.cn/otn/view/index.html'

    def __init__(self, from_station, to_station, train_data):
        self.from_station = from_station
        self.to_station = to_station
        self.train_data = train_data

    def login(self):
        driver.get(self.login_url)
        WebDriverWait(driver, 1000).until(
            ec.url_to_be(self.profile_url)
        )
        print("登陆成功")

    def run(self):
        self.login()


def start():
    spider = TrainSpider('广州', '台山', '2025-10-7')
    spider.run()


if __name__ == '__main__':
    start()
